import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { PayLinkVO, PayLinkForm, PayLinkQuery } from '@/api/system/PayLink/types';

/**
 * 查询支付链接列表
 * @param query
 * @returns {*}
 */

export const listPayLink = (query?: PayLinkQuery): AxiosPromise<PayLinkVO[]> => {
  return request({
    url: '/system/PayLink/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询支付链接详细
 * @param linkId
 */
export const getPayLink = (linkId: string | number): AxiosPromise<PayLinkVO> => {
  return request({
    url: '/system/PayLink/' + linkId,
    method: 'get'
  });
};

/**
 * 新增支付链接
 * @param data
 */
export const addPayLink = (data: PayLinkForm) => {
  return request({
    url: '/system/PayLink',
    method: 'post',
    data: data
  });
};

/**
 * 修改支付链接
 * @param data
 */
export const updatePayLink = (data: PayLinkForm) => {
  return request({
    url: '/system/PayLink',
    method: 'put',
    data: data
  });
};

/**
 * 删除支付链接
 * @param linkId
 */
export const delPayLink = (linkId: string | number | Array<string | number>) => {
  return request({
    url: '/system/PayLink/' + linkId,
    method: 'delete'
  });
};
